package net.lzzy.practices.repositonies;

import net.lzzy.practices.entities.Course;
import net.lzzy.practices.entities.User;
import net.lzzy.practices.web.models.BaseInfo;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.UUID;

/**
 * @author m
 */
public interface CourseRepository extends JpaRepository<Course, UUID> {
    /**
     * 查询所有课程
     * @return 返回课程集合
     */
    List<Course> findAllByOrderByUpdateTimeDesc();

    List<Course> findAllByOrderByUpdateTimeDesc(Pageable page);

    List<Course> findCourseByOpenIsOrderByUpdateTimeDesc(boolean open);

    List<Course> findCourseByOpenIsOrderByUpdateTimeDesc(boolean open,Pageable page);

    Integer countAllBy();

    Integer countCourseByOpenIs(boolean open);

    /**
     * 老师自己创建的课程
     * @param id id
     * @return 课程集合
     */
    //一对多
    List<Course> findCourseByTeacherIdEqualsOrderByUpdateTimeDesc(UUID id);
    //多对多
    List<Course> findCourseByStudentsContainsAndOpenOrderByUpdateTimeDesc(User student,boolean open);





}
